<?php
    
    global $mikron;

    $dirlist_for_month = isset($_REQUEST['month'])?(int)$_REQUEST['month']:(int)date('m', time());
    $dirlist_for_year = isset($_REQUEST['year'])?(int)$_REQUEST['year']:(int)date('Y', time());

    if(isset($_REQUEST['deleteremotedirection']))
    {
        $xml = CreateDeleteRemoteDirectionXML($_REQUEST['deleteremotedirection']);
        CallSoap('deleteremotedirection', $xml);
        $mikron->Tools->GoToPage('/remoterecord/');
    }

        /* ?><p>Запись проведена успешно.</p><?php */
        require_once(dirname(__FILE__).'/remotedirectionslist.inc');
        $record->getdata($dirlist_for_month, $dirlist_for_year);

        $tbl = new html_table(null, 'wintable2', '100%', null, null, Array('Регистрация','Ф.И.О.','Дата рождения','Документ','Полис ОМС','&nbsp;'));

        foreach($record->directions as $direction)
        {
            $tbl->newcol();
                ?><a href="print_preview.php?okremotedirection=<?php echo $direction->guid;?>"><?php echo sprintf('№ %s от %s', $direction->number, $direction->date);?><?php
            $tbl->newcol($direction->patient->fio);
            $tbl->newcol($direction->patient->birthday);
            // $tbl->newcol(substr($direction->patient->sex, 0, 2));
            $tbl->newcol($direction->patient->document);
            $tbl->newcol($direction->patient->policy);
            $tbl->newcol();
                ?><a onclick="return userquery2('Вы действительно хотите удалить направление?');" href="/remoterecord/?deleteremotedirection=<?php echo $direction->guid;?>">Удалить</a><?php
        }
        $tbl->end();
            ?>
     
        <form action="" method="get">
        <table width="100%">
            <tr>
            <td align="right">
                <select name="month" onchange="this.form.submit();">
                    <option value="1">Январь</option>
                    <option value="2">Февраль</option>
                    <option value="3">Март</option>
                    <option value="4">Апрель</option>
                    <option value="5">Май</option>
                    <option value="6">Июнь</option>
                    <option value="7">Июль</option>
                    <option value="8">Август</option>
                    <option value="9">Сентябрь</option>
                    <option value="10">Октябрь</option>
                    <option value="11">Ноябрь</option>
                    <option value="12">Декабрь</option>
                </select>
                <select name="year" onchange="this.form.submit();">
                    <option value="2008">2008</option>
                    <option value="2009">2009</option>
                    <option value="2010">2010</option>
                </select>
            </td>
            </tr>
        </table>
        </form>

        <script language="VBScript">
            function userquery2(text)
                userquery2 = msgbox(text, 4) = 6
            end function
        </script>
        <script type="text/javascript">
            setValue('month', <?php echo $dirlist_for_month; ?>);
            setValue('year', <?php echo $dirlist_for_year; ?>);
            function userquery(text)
            {
                return userquery2(text);
            }
        </script>
